{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "64dffee5",
   "metadata": {},
   "source": [
    "# Synaptic Weights\n",
    "\n",
    "[![Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/brainpy/brainpy/blob/master/docs_version2/tutorial_toolbox/synaptic_weights.ipynb)\n",
    "[![Open in Kaggle](https://kaggle.com/static/images/open-in-kaggle.svg)](https://kaggle.com/kernels/welcome?src=https://github.com/brainpy/brainpy/blob/master/docs_version2/tutorial_toolbox/synaptic_weights.ipynb)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "45063cfc",
   "metadata": {},
   "source": [
    "@[Xiaoyu Chen](mailto:c-xy17@tsinghua.org.cn) "
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2c6e09ce",
   "metadata": {},
   "source": [
    "In a brain model, synaptic weights, the strength of the connection between presynaptic and postsynaptic neurons, are crucial to the dynamics of the model. In this section, we will illutrate how to build synaptic weights in a synapse model."
   ]
  },
  {
   "cell_type": "code",
   "id": "b2699aa1",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-06T05:17:52.532641Z",
     "start_time": "2025-10-06T05:17:47.505343Z"
    }
   },
   "source": [
    "import brainpy as bp\n",
    "import brainpy.math as bm\n",
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "\n",
    "bp.math.set_platform('cpu')"
   ],
   "outputs": [],
   "execution_count": 1
  },
  {
   "cell_type": "code",
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2025-10-06T05:17:52.544215Z",
     "start_time": "2025-10-06T05:17:52.538651Z"
    }
   },
   "source": [
    "bp.__version__"
   ],
   "id": "23c6c2fe06bbd897",
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'3.0.0'"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 2
  },
  {
   "cell_type": "markdown",
   "id": "ab3c64d2",
   "metadata": {},
   "source": [
    "## Creating Static Weights\n",
    "\n",
    "Some computational models focus on the network structure and its influence on network dynamics, thus not modeling neural plasticity for simplicity. In this condition, synaptic weights are fixed and do not change in simulation. They can be stored as a scalar, a matrix or a vector depending on the connection strength and density."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5ac24926",
   "metadata": {},
   "source": [
    "### 1. Storing weights with a scalar\n",
    "\n",
    "If all synaptic weights are designed to be the same, the single weight value can be stored as a scalar in the synpase model to save memory space."
   ]
  },
  {
   "cell_type": "code",
   "id": "f9ecb76d",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-06T05:17:52.550909Z",
     "start_time": "2025-10-06T05:17:52.548221Z"
    }
   },
   "source": [
    "weight = 1."
   ],
   "outputs": [],
   "execution_count": 3
  },
  {
   "cell_type": "markdown",
   "id": "9b1e9cba",
   "metadata": {},
   "source": [
    "The `weight` can be stored in a synapse model. When updating the synapse, this `weight` is assigned to all synapses by scalar multiplication. "
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ca4e17d3",
   "metadata": {},
   "source": [
    "### 2. Storing weights with a matrix\n",
    "\n",
    "**When the synaptic connection is dense and the synapses are assigned with different weights**, weights can be stored in a matrix $W$, where $W(i, j)$ refers to the weight of presynaptic neuron $i$ to postsynaptic neuron $j$.\n",
    "\n",
    "BrainPy provides [`brainpy.initialize.Initializer`](../apis/auto/initialize.rst) (or `brainpy.init` for short) for weight initialization as a matrix. The tutorial of `brainpy.init.Initializer` is introduced later."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "997cecd1",
   "metadata": {},
   "source": [
    "For example, a weight matrix can be constructed using `brainpy.init.Uniform`, which initializes weights with a random distribution:"
   ]
  },
  {
   "cell_type": "code",
   "id": "6e977e0c",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-06T05:17:52.785611Z",
     "start_time": "2025-10-06T05:17:52.554918Z"
    }
   },
   "source": [
    "pre_size = (4, 4)\n",
    "post_size = (3, 3)\n",
    "\n",
    "uniform_init = bp.init.Uniform(min_val=0., max_val=1.)\n",
    "weights = uniform_init((np.prod(pre_size), np.prod(post_size)))\n",
    "print('shape of weights: {}'.format(weights.shape))"
   ],
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "shape of weights: (16, 9)\n"
     ]
    }
   ],
   "execution_count": 4
  },
  {
   "cell_type": "markdown",
   "id": "dd071142",
   "metadata": {},
   "source": [
    "Then, the weights can be assigned to a group of connections with the same shape. For example, an all-to-all connection matrix can be obtained by `brainpy.conn.All2All()` whose tutorial is contained in [Synaptic Connections](synaptic_connections.ipynh):"
   ]
  },
  {
   "cell_type": "code",
   "id": "058a578a",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-06T05:17:52.792526Z",
     "start_time": "2025-10-06T05:17:52.788790Z"
    }
   },
   "source": [
    "conn = bp.conn.All2All()\n",
    "conn(pre_size, post_size)\n",
    "conn_mat = conn.requires('conn_mat')  # request the connection matrix"
   ],
   "outputs": [],
   "execution_count": 5
  },
  {
   "cell_type": "markdown",
   "id": "fd65d53c",
   "metadata": {},
   "source": [
    "Therefore, `weights[i, j]` refers to the weight of connection `(i, j)`."
   ]
  },
  {
   "cell_type": "code",
   "id": "ec98601a",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-06T05:17:52.840377Z",
     "start_time": "2025-10-06T05:17:52.792526Z"
    }
   },
   "source": [
    "i, j = (2, 3)\n",
    "print('whether (i, j) is connected: {}'.format(conn_mat[i, j]))\n",
    "print('synaptic weights of (i, j): {}'.format(weights[i, j]))"
   ],
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "whether (i, j) is connected: True\n",
      "synaptic weights of (i, j): 0.4597054719924927\n"
     ]
    }
   ],
   "execution_count": 6
  },
  {
   "cell_type": "markdown",
   "id": "b0870177",
   "metadata": {},
   "source": [
    "### 3. Storing weights with a vector\n",
    "\n",
    "**When the synaptic connection is sparse, using a matrix to store synaptic weights is too wasteful.** Instead, the weights can be stored in a vector which has the same length as the synaptic connections.\n",
    "\n",
    "<img src=\"../_static/synapses_and_weights.png\" width=\"400 px\">\n",
    "\n",
    "Weights can be assigned to the corresponding synapses as long as the they are aligned with each other."
   ]
  },
  {
   "cell_type": "code",
   "id": "ea8a9701",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-06T05:17:52.861471Z",
     "start_time": "2025-10-06T05:17:52.843665Z"
    }
   },
   "source": [
    "size = 5\n",
    "\n",
    "conn = bp.conn.One2One()\n",
    "conn(size, size)\n",
    "pre_ids, post_ids = conn.requires('pre_ids', 'post_ids')\n",
    "\n",
    "print('presynaptic neuron ids: {}'.format(pre_ids))\n",
    "print('postsynaptic neuron ids: {}'.format(post_ids))\n",
    "print('synapse ids: {}'.format(bm.arange(size)))"
   ],
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "presynaptic neuron ids: [0 1 2 3 4]\n",
      "postsynaptic neuron ids: [0 1 2 3 4]\n",
      "synapse ids: [0 1 2 3 4]\n"
     ]
    }
   ],
   "execution_count": 7
  },
  {
   "cell_type": "markdown",
   "id": "5396727a",
   "metadata": {},
   "source": [
    "The weight vector is aligned with the synapse vector, i.e. synapse ids :"
   ]
  },
  {
   "cell_type": "code",
   "id": "ca329166",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-06T05:17:52.973289Z",
     "start_time": "2025-10-06T05:17:52.865418Z"
    }
   },
   "source": [
    "weights = bm.random.uniform(0, 2, size)\n",
    "\n",
    "for i in range(size):\n",
    "    print('weight of synapse {}: {}'.format(i, weights[i]))"
   ],
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "weight of synapse 0: 1.6773431301116943\n",
      "weight of synapse 1: 0.2750551700592041\n",
      "weight of synapse 2: 1.3642621040344238\n",
      "weight of synapse 3: 1.692277193069458\n",
      "weight of synapse 4: 1.1629705429077148\n"
     ]
    }
   ],
   "execution_count": 8
  },
  {
   "cell_type": "markdown",
   "id": "08c4f292",
   "metadata": {},
   "source": [
    "#### Conversion from a weight matrix to a weight vector\n",
    "For users who would like to obtain the weight vector from the weight matrix, they can first build a connection according to the non-zero elements in the weight matrix and then slice the weight matrix according to the connection:"
   ]
  },
  {
   "cell_type": "code",
   "id": "7cbaa654",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-06T05:17:53.328959Z",
     "start_time": "2025-10-06T05:17:52.977889Z"
    }
   },
   "source": [
    "weight_mat = np.array([[1., 1.5, 0., 0.5], [0., 2.5, 0., 0.], [2., 0., 3, 0.]])\n",
    "print('weight matrix: \\n{}'.format(weight_mat))\n",
    "\n",
    "conn = bp.conn.MatConn(weight_mat)\n",
    "pre_ids, post_ids = conn.requires('pre_ids', 'post_ids')\n",
    "\n",
    "weight_vec = weight_mat[pre_ids, post_ids]\n",
    "print('weight_vector: \\n{}'.format(weight_vec))"
   ],
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "weight matrix: \n",
      "[[1.  1.5 0.  0.5]\n",
      " [0.  2.5 0.  0. ]\n",
      " [2.  0.  3.  0. ]]\n",
      "weight_vector: \n",
      "[1.  1.5 0.5 2.5 2.  3. ]\n"
     ]
    }
   ],
   "execution_count": 9
  },
  {
   "cell_type": "markdown",
   "id": "6a19ba6d",
   "metadata": {},
   "source": [
    "```{note}\n",
    "However, it is not recommended to use this function when the connection is sparse and of a large scale, because generating the weight matrix will take up too much space.\n",
    "```"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5b3f2206",
   "metadata": {},
   "source": [
    "## Creating Dynamic Weights\n",
    "\n",
    "Sometimes users may want to realize neural plasticity in a brain model, which requires the synaptic weights to change during simulation. In this condition, weights should be considered as **variables**, thus defined as `brainpy.math.Variable`. If it is packed in a synapse model, weight updating should be realized in the `update(_t, _dt)` function of the synapse model."
   ]
  },
  {
   "cell_type": "code",
   "id": "24ef9880",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-06T05:17:53.357366Z",
     "start_time": "2025-10-06T05:17:53.332533Z"
    }
   },
   "source": [
    "weights = bm.Variable(bm.ones(10))\n",
    "weights"
   ],
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Variable(\n",
       "  value=ShapedArray(float32[10]),\n",
       "  _batch_axis=None,\n",
       "  axis_names=None\n",
       ")"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 10
  },
  {
   "cell_type": "markdown",
   "id": "32fb2eb1",
   "metadata": {},
   "source": [
    "## Built-in Weight Initializers"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "213e0873",
   "metadata": {},
   "source": [
    "### Base Class: bp.init.Initializer"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c58d1cce",
   "metadata": {},
   "source": [
    "The base class of weight initializers are [`brainpy.initialize.Initializer`](../apis/auto/initialize.rst), which can be accessed by the shortcut `bp.init`. All initializers, built-in or costumized, should inherit the `Initializer` class. \n",
    "\n",
    "Weight initialization is implemented in the `__call__` function, so that it can be realized automatically when the initializer is called. The `__call__` function has a `shape` parameter that has different meanings in the following two superclasses and returns a **weight matrix**."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a24b8aa6",
   "metadata": {},
   "source": [
    "### Superclass 1: bp.init.InterLayerInitializer"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8ca9519d",
   "metadata": {},
   "source": [
    "The [`InterLayerInitializer`](../apis/auto/initialize.rst) is an abstract subclass of `Initializer`. Its subclasses initialize the weights between two fully connected layers. The `shape` parameter of the `__call__` function should be a 2-element tuple $(m, n)$, which refers to the number of presynaptic neurons $m$ and of postsynaptic neurons $n$. The output of the `__call__` function is a `bp.math.ndarray` with the shape of $(m, n)$, where the value at $(i, j)$ is the initialized weight of the presynaptic neuron $i$ to postsynpatic neuron $j$."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f35f412e",
   "metadata": {},
   "source": [
    "### Superclass 2: bp.init.IntraLayerInitializer"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3849330b",
   "metadata": {},
   "source": [
    "The [`IntraLayerInitializer`](../apis/auto/initialize.rst) is also an abstract subclass of `Initializer`. Its subclasses initialize the weights within a single layer. The `shape` parameter of the `__call__` function refers to the the structure of the neural population $(n_1, n_2, ..., n_d)$. The `__call__` function returns a 2-D `bp.math.ndarray` with the shape of $(\\prod_{k=1}^d n_k, \\prod_{k=1}^d n_k)$. In the 2-D array, the value at $(i, j)$ is the initialized weight of neuron $i$ to neuron $j$ of the flattened neural sequence."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "03ff759c",
   "metadata": {},
   "source": [
    "### 1. Built-In Regular Initializers"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b4174c05",
   "metadata": {},
   "source": [
    "Regular initializers all belong to `InterLayerInitializer` and initialize the connection weights between two layers with a regular pattern. There are `ZeroInit`, `OneInit`, and `Identity` initializers in built-in regular initializers. Here we show how to use the `OneInit` initializer. The remaining two classes are used in a similar way."
   ]
  },
  {
   "cell_type": "code",
   "id": "9ffc2667",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-06T05:17:53.365628Z",
     "start_time": "2025-10-06T05:17:53.360751Z"
    }
   },
   "source": [
    "# visualization\n",
    "def mat_visualize(matrix, cmap=plt.cm.get_cmap('coolwarm')):\n",
    "    im = plt.matshow(matrix, cmap=cmap)\n",
    "    plt.colorbar(mappable=im, shrink=0.8, aspect=15)\n",
    "    plt.show()"
   ],
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\adadu\\AppData\\Local\\Temp\\ipykernel_55772\\1240014358.py:2: MatplotlibDeprecationWarning: The get_cmap function was deprecated in Matplotlib 3.7 and will be removed in 3.11. Use ``matplotlib.colormaps[name]`` or ``matplotlib.colormaps.get_cmap()`` or ``pyplot.get_cmap()`` instead.\n",
      "  def mat_visualize(matrix, cmap=plt.cm.get_cmap('coolwarm')):\n"
     ]
    }
   ],
   "execution_count": 11
  },
  {
   "cell_type": "code",
   "id": "74de43f3",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-06T05:17:53.412237Z",
     "start_time": "2025-10-06T05:17:53.367181Z"
    }
   },
   "source": [
    "# 'OneInit' initializes all the weights with the same value\n",
    "shape = (5, 6)\n",
    "one_init = bp.init.OneInit(value=2.5)\n",
    "weights = one_init(shape)\n",
    "print(weights)"
   ],
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[2.5 2.5 2.5 2.5 2.5 2.5]\n",
      " [2.5 2.5 2.5 2.5 2.5 2.5]\n",
      " [2.5 2.5 2.5 2.5 2.5 2.5]\n",
      " [2.5 2.5 2.5 2.5 2.5 2.5]\n",
      " [2.5 2.5 2.5 2.5 2.5 2.5]]\n"
     ]
    }
   ],
   "execution_count": 12
  },
  {
   "cell_type": "markdown",
   "id": "5330484f",
   "metadata": {},
   "source": [
    "### 2. Built-In Random Initializers"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "966110e9",
   "metadata": {},
   "source": [
    "Random initializers all belong to `InterLayerInitializer` and initialize the connection weights between two layers with a random distribution. There are `Normal`, `Uniform`, `Orthogonal` and other initializers in built-in regular initializers. Here we show how to use the `Normal` and `Uniform` initializers."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1328b075",
   "metadata": {},
   "source": [
    "**bp.init.Normal**\n",
    "\n",
    "This initializer initializes the weights with a normal distribution. The variance of the distribution changes according to the `scale` parameter. In the following example, 10 presynaptic neurons are fully connected to 20 postsynaptic neurons with random weight values:"
   ]
  },
  {
   "cell_type": "code",
   "id": "740a351d",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-06T05:17:53.855160Z",
     "start_time": "2025-10-06T05:17:53.416170Z"
    }
   },
   "source": [
    "shape = (10, 20)\n",
    "normal_init = bp.init.Normal(scale=1.0)\n",
    "weights = normal_init(shape)\n",
    "mat_visualize(weights)"
   ],
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Figure size 960x480 with 2 Axes>"
      ],
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAtEAAAFaCAY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qnleAH/G/jwww9VVFQUZEgAAIAup7q6Wv3797edhiTpzJkzKi4uVk1NjbE1CwoKVFVVpezsbGNrmhR4Ee26ro4dO6bc3Fw5jnPRr0smkyoqKlJ1dbXi8XgKM0Sm4JqCaVxTMI1rCufjeZ7q6upUWFioSCQ8e0ScOXNGTU3m/mtaVlZWaAtoycI4RyQS6dRvTfF4nA8SGMU1BdO4pmAa1xS+LJFI2E7hK7Kzs0Nd9JoWnl9fAAAAgDRBEQ0AAAD4lDZFdCwW04oVKxSLxWyngi6CawqmcU3BNK4pILwCv7EQAAAASHdp04kGAAAAwoIiGgAAAPCJIhoAAADwiSIaAAAA8IkiGgAAAPCJIhoAAADwiSIaAAAA8IkiGgAAAPDp/wNWZ49a4B4FIwAAAABJRU5ErkJggg=="
     },
     "metadata": {},
     "output_type": "display_data",
     "jetTransient": {
      "display_id": null
     }
    }
   ],
   "execution_count": 13
  },
  {
   "cell_type": "markdown",
   "id": "e7e05dcb",
   "metadata": {},
   "source": [
    "**bp.init.Uniform**\n",
    "\n",
    "This initializer resembles `brainpy.init.Normal` but initializes the weights with a uniform distribution."
   ]
  },
  {
   "cell_type": "code",
   "id": "b8f46814",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-06T05:17:54.020132Z",
     "start_time": "2025-10-06T05:17:53.860171Z"
    }
   },
   "source": [
    "uniform_init = bp.init.Uniform(min_val=0., max_val=1.)\n",
    "weights = uniform_init(shape)\n",
    "mat_visualize(weights)"
   ],
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Figure size 960x480 with 2 Axes>"
      ],
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAtIAAAFaCAYAAAAzYbqCAAAAOnRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjEwLjYsIGh0dHBzOi8vbWF0cGxvdGxpYi5vcmcvq6yFwwAAAAlwSFlzAAAPYQAAD2EBqD+naQAAJ+5JREFUeJzt3X90FfWd//HX3Au5CZBEMCQhGAhQFZ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76+XhdccIHf05AkHT9+XCNGjFBDQ4OxMbOzs7V//34lJycbG9M0zwtp27b1zjvvKDU1VZZl9fh90WhUubm5qq+vV1pa2lmcIRIF1xRM45qCaVxT6I7jODpy5IhycnIUCsXPvhHHjx9XW5u5/xORlJQU10W05ENrRygU6tW/ntLS0vgwgVFcUzCNawqmcU3h76Wnp/s9hVMkJyfHfeFrWvz8MwYAAAAIEAppAAAAwIXAFNKRSERlZWWKRCJ+TwXnCK4pmMY1BdO4poD45vnNhgAAAMC5IDAr0gAAAEA8oZAGAAAAXKCQBgAAAFygkAYAAABcoJAGAAAAXKCQBgAAAFygkAYAAABcoJAGAAAAXPj/wRnIgeTsqscAAAAASUVORK5CYII="
     },
     "metadata": {},
     "output_type": "display_data",
     "jetTransient": {
      "display_id": null
     }
    }
   ],
   "execution_count": 14
  },
  {
   "cell_type": "markdown",
   "id": "53af0205",
   "metadata": {},
   "source": [
    "### 3. Built-In Decay Initializers"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "99e2fd32",
   "metadata": {},
   "source": [
    "Decay initializers all belong to `IntraLayerInitializer` and initialize the connection weights within a layer with a decay function according to the neural distance. There are `GaussianDecay` and `DOGDecay` initializers in built-in decay initializers. Below are examples of how to use them."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d4bc2acd",
   "metadata": {},
   "source": [
    "**brainpy.training.initialize.GaussianDecay**\n",
    "\n",
    "This initializer creates a Gaussian connectivity pattern within a population of neurons, where the weights decay with a gaussian function.\n",
    "Specifically, for any pair of neurons $ (i, j) $, the weight is computed as\n",
    "\n",
    "$$\n",
    "w(i, j) = w_{max} \\cdot \\exp(-\\frac{\\sum_{k=1}^n |v_k^i - v_k^j|^2 }{2\\sigma^2})\n",
    "$$\n",
    "\n",
    "where $ v_k^i $ is the $ i $-th neuron's encoded value (position) at dimension $ k $.\n",
    "\n",
    "The example below is a neural population with the size of $ 5 \\times 5 $. Note that this shape is the structure of the target neural population, not the size of presynaptic and postsynaptic neurons."
   ]
  },
  {
   "cell_type": "code",
   "id": "9e934691",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-06T05:17:54.144474Z",
     "start_time": "2025-10-06T05:17:54.026506Z"
    }
   },
   "source": [
    "size = (5, 5)\n",
    "gaussian_init = bp.init.GaussianDecay(sigma=2., max_w=10., include_self=True)\n",
    "weights = gaussian_init(size)\n",
    "print('shape of weights: {}'.format(weights.shape))"
   ],
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "shape of weights: (25, 25)\n"
     ]
    }
   ],
   "execution_count": 15
  },
  {
   "cell_type": "markdown",
   "id": "25221a9f",
   "metadata": {},
   "source": [
    "Self-connections are created if `include_self=True`. The connection weights of neuron $i$ with others are stored in row $i$ of `weights`. For instance, the connection weights of neuron(1, 2) to other neurons are stored in `weights[7]` ($5 \\times 1 +2 = 7$). After reshaping, the weights are:"
   ]
  },
  {
   "cell_type": "code",
   "id": "bab70873",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-06T05:17:54.235619Z",
     "start_time": "2025-10-06T05:17:54.147770Z"
    }
   },
   "source": [
    "mat_visualize(weights[0].reshape(size), cmap=plt.cm.get_cmap('Reds'))"
   ],
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\adadu\\AppData\\Local\\Temp\\ipykernel_55772\\830981930.py:1: MatplotlibDeprecationWarning: The get_cmap function was deprecated in Matplotlib 3.7 and will be removed in 3.11. Use ``matplotlib.colormaps[name]`` or ``matplotlib.colormaps.get_cmap()`` or ``pyplot.get_cmap()`` instead.\n",
      "  mat_visualize(weights[0].reshape(size), cmap=plt.cm.get_cmap('Reds'))\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "<Figure size 480x480 with 2 Axes>"
      ],
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAZEAAAFaCAYAAADfDmAgAAAAOnRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjEwLjYsIGh0dHBzOi8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clfW8Q+TQoUMGygCAAGNNBADgHZ0IAMArOhEAgGeECADAu+BOZxXfuxYBACWDTgQALHMcR46BqSgT+zCNEAEA21gTAQB4F9w1EUIEAKwz9S4QQgQAyg/TWQAA74I7ncUlvgAAz+hEAMA2prMAAJ4FdzaLEAEA+4KbIoQIANjGdBYAwDNCBADgHdNZAACvHBnqRPLfhWncJwIA8IxOBABsY00EAOAdayLGuK4rSUoNDBb60P4JlVFWn/uP3xUUVnrI7woKxrnqv/wuoSBS/f2SPvldZWSfAwNGuojUwICBaswq+G+3/o//A9X/b1OhDw0AV6y/v1+xWCyvfVRWVmrKlCmq+58ZhqqSpkyZosrKSmP7y5fjmozbKzA8PKxTp04pEokU7FWPqVRKdXV1SiaTikajBTmmn8rpfMvpXKXyOl+/ztV1XfX396umpkahUP7XHp09e1bnzp0zUNmIyspKVVVVGdtfvgreiYRCIdXW1hb6sJKkaDQa+P/xPq2czreczlUqr/P141zz7UA+raqqqqh+6ZvGJb4AAM8IEQCAZ2URIuFwWBs2bFA4HPa7lIIop/Mtp3OVyut8y+lcS1nBF9YBAMFRFp0IAMAOQgQA4BkhAgDwjBABAHhGiAAAPCNEAACeESIAAM8IEQCAZ/8POIoXbKSn4R0AAAAASUVORK5CYII="
     },
     "metadata": {},
     "output_type": "display_data",
     "jetTransient": {
      "display_id": null
     }
    }
   ],
   "execution_count": 16
  },
  {
   "cell_type": "markdown",
   "id": "7d558517",
   "metadata": {},
   "source": [
    "**brainpy.training.initialize.DOGDecay**\n",
    "\n",
    "This initializer creates a Difference-Of-Gaussian (DOG) connectivity pattern within a population of neurons. Specifically, for the given pair of neurons $ (i, j) $, the weight between them is computed as\n",
    "\n",
    "$$\n",
    "w(i, j) = w_{max}^+ \\cdot \\exp(-\\frac{\\sum_{k=1}^n |v_k^i - v_k^j|^2}{2\\sigma_+^2}) - w_{max}^- \\cdot \\exp(-\\frac{\\sum_{k=1}^n |v_k^i - v_k^j|^2}{2\\sigma_-^2})\n",
    "$$\n",
    "\n",
    "where $ v_k^i $ is the $ i $-th neuron's encoded value (position) at dimension $ k $.\n",
    "\n",
    "<center><img src=\"../_static/DOGDecay.png\" width=\"300 px\"></center>\n",
    "\n",
    "The example below is a neural population with the size of $ 10 \\times 12 $:"
   ]
  },
  {
   "cell_type": "code",
   "id": "470b71ac",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-06T05:17:54.342253Z",
     "start_time": "2025-10-06T05:17:54.241704Z"
    }
   },
   "source": [
    "size = (10, 12)\n",
    "dog_init = bp.init.DOGDecay(sigmas=(1., 3.), max_ws=(10., 5.), min_w=0.1, include_self=True)\n",
    "weights = dog_init(size)\n",
    "print('shape of weights: {}'.format(weights.shape))"
   ],
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "shape of weights: (120, 120)\n"
     ]
    }
   ],
   "execution_count": 17
  },
  {
   "cell_type": "markdown",
   "id": "21a51689",
   "metadata": {},
   "source": [
    "Weights smaller than `min_w` will not be created. `min_w` $ = 0.005 \\times min( $ `max_ws` $ ) $ if it is not assigned with a value.\n",
    "The organization of `weights` is similar to that in the `GaussianDecay` initializer. For instance, the connection weights of neuron (3, 4) to other neurons after reshaping are shown as below:"
   ]
  },
  {
   "cell_type": "code",
   "id": "06b14d81",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-06T05:17:54.443005Z",
     "start_time": "2025-10-06T05:17:54.345690Z"
    }
   },
   "source": [
    "mat_visualize(weights[3*12+4].reshape(size), cmap=plt.cm.get_cmap('Reds'))"
   ],
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\adadu\\AppData\\Local\\Temp\\ipykernel_55772\\2141995340.py:1: MatplotlibDeprecationWarning: The get_cmap function was deprecated in Matplotlib 3.7 and will be removed in 3.11. Use ``matplotlib.colormaps[name]`` or ``matplotlib.colormaps.get_cmap()`` or ``pyplot.get_cmap()`` instead.\n",
      "  mat_visualize(weights[3*12+4].reshape(size), cmap=plt.cm.get_cmap('Reds'))\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "<Figure size 576x480 with 2 Axes>"
      ],
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAdQAAAFcCAYAAABxxE/ZAAAAOnRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjEwLjYsIGh0dHBzOi8vbWF0cGxvdGxpYi5vcmcvq6yFwwAAAAlwSFlzAAAPYQAAD2EBqD+naQAAJC9JREFUeJzt3X9wVfWd//HXucHcBMiNgOFHhgSCWiggFAFdwOlCyYosZcvu1KpL3YiOs+uGCqTbFboDgXHxStdl2SoTfsxWmO+I4G4XbZ1Rh6YCwygCoTiyFRSr5QpC+FFySZAbuPd8/6CJvRKQy/18zrk39/nofMbmkPt5v89I8vb9Oed8juO6risAAJCWgN8JAADQGVBQAQAwgIIKAIABFFQAAAygoAIAYAAFFQAAAyioAAAYQEEFAMAACioAAAZQUAEAMCBrCurKlSs1cOBAFRQU6M4779SuXbv8TsmKcDissWPHqqioSL1799aMGTN08OBBv9PyxNNPPy3HcTR37ly/U7HmyJEj+v73v69evXqpsLBQt912m/bs2eN3WsbF43EtXLhQFRUVKiws1M0336wnn3xSnWWn0+3bt2v69OkqLS2V4zh6+eWXk/7cdV0tWrRI/fr1U2FhoSorK/Xhhx/6kyw8kxUFddOmTaqpqVFtba327t2rkSNHasqUKWpsbPQ7NeO2bdum6upq7dy5U1u2bNGFCxd09913q6Wlxe/UrNq9e7dWr16tESNG+J2KNX/4wx80YcIE3XDDDXrttdf029/+Vv/+7/+uHj16+J2accuWLVNdXZ2ee+45vf/++1q2bJl+8pOf6Nlnn/U7NSNaWlo0cuRIrVy5ssM//8lPfqKf/vSnWrVqld555x1169ZNU6ZM0fnz5z3OFJ5ys8Add9zhVldXt38dj8fd0tJSNxwO+5iVNxobG11J7rZt2/xOxZqzZ8+6t956q7tlyxb3z//8z905c+b4nZIVTzzxhHvXXXf5nYYnpk2b5j788MNJx/7mb/7GnTlzpk8Z2SP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SJRBQKhSxmmBk4384rl85Vyq3zzcZzdV1XZ8+eVWlpqQIBsytM58+fV2uruU7fdd3L6saVOtT58+dr2bJlV53v/fff15AhQyRJJ0+e1OnTp/X73/9eS5YsUXFxsV599dWU6pTnBfV6RaNRFRcXq6mpKWv+oqaD8+28culcpdw631w610x34sQJnTp16qrfM2jQIOXn5192/NNPP1VZWZneeustjRs37ppjclMSAKDTKSkpUUlJyXV9NpG4dI9CLJbafTcUVABAznrnnXe0e/du3XXXXerRo4c++ugjLVy4UDfffHNK3amURc+hBoNB1dbWGr2bK5Nxvp1XLp2rlFvnm0vn2ll07dpV//u//6vJkydr8ODBeuSRRzRixAht27Yt5X+PWXMNFQCATJY1HSoAAJmMggoAgAEUVAAADKCgAgBgAAUVAAADKKgAABhAQQUAwAAKKgAABlBQAQAwgIIKAIABFFQAAAz4/zeBqF6upXi9AAAAAElFTkSuQmCC"
     },
     "metadata": {},
     "output_type": "display_data",
     "jetTransient": {
      "display_id": null
     }
    }
   ],
   "execution_count": 18
  },
  {
   "cell_type": "markdown",
   "id": "1ced449e",
   "metadata": {},
   "source": [
    "## Customizing your initializers"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "72862e34",
   "metadata": {},
   "source": [
    "BrainPy also allows users to customize the weight initializers of their own. When customizing a initializer, users should follow the instructions below:\n",
    "- Your initializer should inherit `brainpy.initialize.Initializer`.\n",
    "- Override the `__call__` funtion, to which the `shape` parameter should be given.\n",
    "\n",
    "Here is an example of creating an inter-layer initializer that initialize the weights as follows:\n",
    "\n",
    "$$\n",
    "w(i, j) = max(w_{max} - \\sigma |v_i - v_j|, 0)\n",
    "$$"
   ]
  },
  {
   "cell_type": "code",
   "id": "e85bb54b",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-06T05:17:54.450824Z",
     "start_time": "2025-10-06T05:17:54.446150Z"
    }
   },
   "source": [
    "class LinearDecay(bp.init.Initializer):\n",
    "    def __init__(self, max_w, sigma=1.):\n",
    "        self.max_w = max_w\n",
    "        self.sigma = sigma\n",
    "    \n",
    "    def __call__(self, shape, dtype=None):\n",
    "        mat = bp.math.zeros(shape, dtype=dtype)\n",
    "        n_pre, n_post = shape\n",
    "        seq = np.arange(n_pre)\n",
    "        current_w = self.max_w\n",
    "        \n",
    "        for i in range(max(n_pre, n_post)):\n",
    "            if current_w <= 0:\n",
    "                break\n",
    "            seq_plus = ((seq + i) >= 0) & ((seq + i) < n_post)\n",
    "            seq_minus = ((seq - i) >= 0) & ((seq - i) < n_post)\n",
    "            mat[seq[seq_plus], (seq + i)[seq_plus]] = current_w\n",
    "            mat[seq[seq_minus], (seq - i)[seq_minus]] = current_w\n",
    "            current_w -= self.sigma\n",
    "        \n",
    "        return mat"
   ],
   "outputs": [],
   "execution_count": 19
  },
  {
   "cell_type": "code",
   "id": "406361a3",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-06T05:17:55.626238Z",
     "start_time": "2025-10-06T05:17:54.453831Z"
    }
   },
   "source": [
    "shape = (10, 15)\n",
    "lin_init = LinearDecay(max_w=5, sigma=1.)\n",
    "weights = lin_init(shape)\n",
    "mat_visualize(weights, cmap=plt.cm.get_cmap('Reds'))"
   ],
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\adadu\\AppData\\Local\\Temp\\ipykernel_55772\\1681659888.py:4: MatplotlibDeprecationWarning: The get_cmap function was deprecated in Matplotlib 3.7 and will be removed in 3.11. Use ``matplotlib.colormaps[name]`` or ``matplotlib.colormaps.get_cmap()`` or ``pyplot.get_cmap()`` instead.\n",
      "  mat_visualize(weights, cmap=plt.cm.get_cmap('Reds'))\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "<Figure size 720x480 with 2 Axes>"
      ],
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAicAAAFdCAYAAADYAc3nAAAAOnRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjEwLjYsIGh0dHBzOi8vbWF0cGxvdGxpYi5v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izp0/f151dXVauHBhxzmfz6fCwkK9/fbbnY5pe3HS/NVNZmVl2R0aAADHNDc3Kz09PeZxkpKSlJGRoazv5lg2Zu/evS/5u11RUaElS5ZEnDt9+rTC4bAGDBgQcX7AgAF6//33Ox3P9uIkMzNTwWBQqampMqJoFYVCIWVlZSkYDCotLS2GGboD9+tdiXSvUmLdbyLdq5RY99udezVNU83NzcrMzIxRdpGSk5N1/PhxnT9/3rIxTdO85G/2N7smVrK9OPH5fBo0aFCXr09LS/P8L8HXcb/elUj3KiXW/SbSvUqJdb9dvVc7OiZfl5ycrOTkZFtjStINN9wgv9+vU6dORZw/deqUMjIyOj0OC2IBAIAlkpKSNG7cOFVXV3eca2trU3V1tSZOnNjpcXgIGwAAsEx5ebmKi4uVl5en/Px8rV69Wi0tLSopKen0GHFTnAQCAVVUVMR0jstNuF/vSqR7lRLrfhPpXqXEut9Eutfuuvfee/X5559r8eLFOnnypG655Rbt3LnzkkWyV2OYdu9tAgAAuArWnAAAAFehOAEAAK5CcQIAAFyF4gQAALgKxQkAAHAVihMAAOAqFCcAAMBVKE4AAICrUJwAAABXoTgBAACuQnECAABc5f8DyMokzK73cQoAAAAASUVORK5CYII="
     },
     "metadata": {},
     "output_type": "display_data",
     "jetTransient": {
      "display_id": null
     }
    }
   ],
   "execution_count": 20
  },
  {
   "cell_type": "markdown",
   "id": "e393c1be",
   "metadata": {},
   "source": [
    "```{note}\n",
    "Note that customized initializers, or ``brainpy.init.Initializer``, is not limited to returning a matrix. Although currently all the built-in initializers use matrix to store weights, they can also be designed to return a vector to store synaptic weights.\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "id": "a863067e",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-06T05:17:57.912322Z",
     "start_time": "2025-10-06T05:17:57.909685Z"
    }
   },
   "source": [],
   "outputs": [],
   "execution_count": null
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
